package com.zhilianbao.leyaogo.ui.activity.search;

import android.os.Bundle;

import com.bql.fragmentation.anim.DefaultNoAnimator;
import com.bql.fragmentation.anim.FragmentAnimator;
import com.bql.utils.EventManager;
import com.zhilianbao.leyaogo.R;
import com.zhilianbao.leyaogo.constants.IntentConfig;
import com.zhilianbao.leyaogo.events.LeEventCode;
import com.zhilianbao.leyaogo.ui.activity.base.BaseOkHttpActivity;
import com.zhilianbao.leyaogo.ui.fragment.search.SearchFragment;

import java.util.List;

/**
 * ClassName: SearchActivity <br>
 * Description: 搜索Activity<br>
 * Author: Cyarie <br>
 * Created: 2016/10/25 19:19 <br>
 * Update Time：<br>
 * Update Description：<br>
 */
public class SearchActivity extends BaseOkHttpActivity {

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.fragment_container;
    }

    @Override
    protected void initViewsAndEvents(Bundle savedInstanceState) {
        if (savedInstanceState == null) {
            loadRootFragment(R.id.fl_container, SearchFragment.getInstance((List<String>) getIntent().getSerializableExtra(IntentConfig.HOT_SEARCH_LIST)));
        }
    }

    @Override
    protected FragmentAnimator onCreateFragmentAnimator() {
        return new DefaultNoAnimator();
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return true;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return TransitionMode.NONE;
    }

    @Override
    protected void onHandleEvent(EventManager eventManager) {
        super.onHandleEvent(eventManager);
        switch (eventManager.getEventCode()){
            case LeEventCode.MSG_CODE_SWITCH_TO_HOME:
                finish();
                break;
        }
    }
}
